class supplier{

	static initSupplier(supSelectObjId,selectedSupNo) {
		debugger;
		$.ajax({
			type : 'get',
			url : '/pSuppliers/listAll',
			async : false,
			success : function(data) {
				if(data.code==0 && data.data.list){
					supplier.showSelect(supSelectObjId,data.data.list,1,selectedSupNo);
				}

			}
		});
	}

	static  showSelect(id, data, all , checked) {
		var select = $("#" + id);
		select.empty();

		if (all != undefined || all) {
			select.append("<option value=''>请选择</option>");
		}

		$.each(data, function(k, v) {
			let key = v.supplierNo;
			let value = v.supplierName;
			let checkedHtml = "";
			if(checked!=null && key == checked){
				checkedHtml = " selected = 'selected' ";
			}
			select.append("<option value ='" + key + "' "+ checkedHtml +" >" + value + "</option>");
		});

		return data;
	}
}